import R from "@common/type/response";
import { NextApiResponse } from "next";
import { SysLogininforService } from '@/common/service/sys_logininfor';
import { AuthenticatedRequest, withAuth } from '@common/middleware/auth';

export async function handler(req: AuthenticatedRequest, res: NextApiResponse) {
    const { id } = req.query;
    const info_id = Number(id);

    if (req.method === 'GET') {
        const data = await SysLogininforService.getLogininforById(info_id);
        R.success(res, data);
    } else if (req.method === 'DELETE') {
        const result = await SysLogininforService.deleteLogininfor(info_id);
        R.success(res, { deleted: result });
    } else {
        R.error(res, '不支持的请求方法');
    }
}

export default withAuth(handler); 